using System;
using bitzhuwei.Compiler;

namespace bitzhuwei.AnsiCFormat {
    /// <summary>
    /// Correspond to the Vn node iteration_statement in the grammar(AnsiC).
    /// </summary>
    internal partial class Vniteration_statement : IFullFormat {
        // [194] iteration_statement = 'while' '(' expression ')' statement ;
        // [195] iteration_statement = 'do' statement 'while' '(' expression ')' ';' ;
        // [196] iteration_statement = 'for' '(' expression_statement expression_statement ')' statement ;
        // [197] iteration_statement = 'for' '(' expression_statement expression_statement expression ')' statement ;


        private readonly IFullFormat complex;

        private readonly TokenRange _scope;
        public TokenRange Scope => _scope;
        public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
            context.PrintBlanksAnd(this.complex, preConfig, writer);
        }


        // [194] iteration_statement = 'while' '(' expression ')' statement ;
        public Vniteration_statement(Token r4, Token r3, Vnexpression r2, Token r1, Vnstatement r0) {
            this.complex = new complex0(r4, r3, r2, r1, r0);
            this._scope = new TokenRange(r4, r0);
        }
        class complex0 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r4, preConfig, writer);
                context.PrintCommentsBetween(r4, r3, config, writer);
                context.PrintBlanksAnd(r3, config, writer);
                context.PrintCommentsBetween(r3, r2, config, writer);
                context.PrintBlanksAnd(r2, config, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r4;
            public readonly Token r3;
            public readonly Vnexpression r2;
            public readonly Token r1;
            public readonly Vnstatement r0;
            public complex0(Token r4, Token r3, Vnexpression r2, Token r1, Vnstatement r0) {
                this.r4 = r4;
                this.r3 = r3;
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r4, r0);
            }
        }

        // [195] iteration_statement = 'do' statement 'while' '(' expression ')' ';' ;
        public Vniteration_statement(Token r6, Vnstatement r5, Token r4, Token r3, Vnexpression r2, Token r1, Token r0) {
            this.complex = new complex1(r6, r5, r4, r3, r2, r1, r0);
            this._scope = new TokenRange(r6, r0);
        }
        class complex1 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r6, preConfig, writer);
                context.PrintCommentsBetween(r6, r5, config, writer);
                context.PrintBlanksAnd(r5, config, writer);
                context.PrintCommentsBetween(r5, r4, config, writer);
                context.PrintBlanksAnd(r4, config, writer);
                context.PrintCommentsBetween(r4, r3, config, writer);
                context.PrintBlanksAnd(r3, config, writer);
                context.PrintCommentsBetween(r3, r2, config, writer);
                context.PrintBlanksAnd(r2, config, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r6;
            public readonly Vnstatement r5;
            public readonly Token r4;
            public readonly Token r3;
            public readonly Vnexpression r2;
            public readonly Token r1;
            public readonly Token r0;
            public complex1(Token r6, Vnstatement r5, Token r4, Token r3, Vnexpression r2, Token r1, Token r0) {
                this.r6 = r6;
                this.r5 = r5;
                this.r4 = r4;
                this.r3 = r3;
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r6, r0);
            }
        }

        // [196] iteration_statement = 'for' '(' expression_statement expression_statement ')' statement ;
        public Vniteration_statement(Token r5, Token r4, Vnexpression_statement r3, Vnexpression_statement r2, Token r1, Vnstatement r0) {
            this.complex = new complex2(r5, r4, r3, r2, r1, r0);
            this._scope = new TokenRange(r5, r0);
        }
        class complex2 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r5, preConfig, writer);
                context.PrintCommentsBetween(r5, r4, config, writer);
                context.PrintBlanksAnd(r4, config, writer);
                context.PrintCommentsBetween(r4, r3, config, writer);
                context.PrintBlanksAnd(r3, config, writer);
                context.PrintCommentsBetween(r3, r2, config, writer);
                context.PrintBlanksAnd(r2, config, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r5;
            public readonly Token r4;
            public readonly Vnexpression_statement r3;
            public readonly Vnexpression_statement r2;
            public readonly Token r1;
            public readonly Vnstatement r0;
            public complex2(Token r5, Token r4, Vnexpression_statement r3, Vnexpression_statement r2, Token r1, Vnstatement r0) {
                this.r5 = r5;
                this.r4 = r4;
                this.r3 = r3;
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r5, r0);
            }
        }

        // [197] iteration_statement = 'for' '(' expression_statement expression_statement expression ')' statement ;
        public Vniteration_statement(Token r6, Token r5, Vnexpression_statement r4, Vnexpression_statement r3, Vnexpression r2, Token r1, Vnstatement r0) {
            this.complex = new complex3(r6, r5, r4, r3, r2, r1, r0);
            this._scope = new TokenRange(r6, r0);
        }
        class complex3 : IFullFormat {
            private readonly TokenRange _scope;
            public TokenRange Scope => _scope;
            public void FullFormat(BlankConfig? preConfig, TextWriter writer, FormatContext context) {
                var config = new BlankConfig();
                context.PrintBlanksAnd(r6, preConfig, writer);
                context.PrintCommentsBetween(r6, r5, config, writer);
                context.PrintBlanksAnd(r5, config, writer);
                context.PrintCommentsBetween(r5, r4, config, writer);
                context.PrintBlanksAnd(r4, config, writer);
                context.PrintCommentsBetween(r4, r3, config, writer);
                context.PrintBlanksAnd(r3, config, writer);
                context.PrintCommentsBetween(r3, r2, config, writer);
                context.PrintBlanksAnd(r2, config, writer);
                context.PrintCommentsBetween(r2, r1, config, writer);
                context.PrintBlanksAnd(r1, config, writer);
                context.PrintCommentsBetween(r1, r0, config, writer);
                context.PrintBlanksAnd(r0, config, writer);
            }
            public readonly Token r6;
            public readonly Token r5;
            public readonly Vnexpression_statement r4;
            public readonly Vnexpression_statement r3;
            public readonly Vnexpression r2;
            public readonly Token r1;
            public readonly Vnstatement r0;
            public complex3(Token r6, Token r5, Vnexpression_statement r4, Vnexpression_statement r3, Vnexpression r2, Token r1, Vnstatement r0) {
                this.r6 = r6;
                this.r5 = r5;
                this.r4 = r4;
                this.r3 = r3;
                this.r2 = r2;
                this.r1 = r1;
                this.r0 = r0;
                this._scope = new TokenRange(r6, r0);
            }
        }



    }
}
